{extend name="panel/layout" /}
{block name="main"}
<div class="row">
    {if isset($kms)}
    <div class="col-md-12">
        <div class="panel">
            <div class="panel-heading">生成的卡密</div>
            <div class="panel-body">
                {$kms}
            </div>
        </div>
    </div>
    {/if}
    <div class="col-md-12">
        <div class="panel">
            <div class="panel-heading">卡密生成-每张卡密：{$priceAll} 金币
            <span class="pull-right">
                    <label class="label label-success pull-right">
                        剩余金币：{$userInfo.point}
                    </label>
                </span></div>
            <div class="panel-body">
                <div class="alert alert-info"><i class="fa fa-volume-up"></i>&nbsp;
                    API地址：http://{$_SERVER['HTTP_HOST']}/<br/>
                    <i class="fa fa-volume-up"></i>&nbsp; 在彩虹云任务后台选择自定义代挂接口，并填写以上地址，即可完成对接。
                </div>
            </div>
            <div class="panel-body">
                <form method="post" class="form-horizontal">
                    <input type="hidden" name="action" value="add">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">开通月数:</label>
                        <div class="col-sm-9">
                            <input type="number" min="1" max="1000" name="value"
                                   placeholder="输入要生成卡密的开通月数！（最低1个月，最高12个月）" class="form-control"
                                   required>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">生成卡数量:</label>
                        <div class="col-sm-9">
                            <input name="num" type="number" min="1" max="100"
                                   placeholder="输入要生成多少张卡密！(最低1张，最高100张）"
                                   class="form-control" required>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-sm-offset-3 col-sm-9">
                            <button class="btn btn-success" type="submit">&lt;&lt;&lt;生成&gt;&gt;&gt;</button>
                            &nbsp; &nbsp; <a href="?action=clean" class="btn btn-space btn-danger">清空已使用</a>
                        </div>
                    </div>
                </form>

            </div>
        </div>
        <div class="panel">
            <div class="panel-heading">卡密列表</div>
            <div class="panel-body">
                <form method="post">
                    <input type="hidden" name="action" value="search">
                    <div class="input-group xs-mb-15">
                        <input type="text" placeholder="请输入要搜索的卡密！" name="s"
                               class="form-control text-center"
                               required>
                        <span class="input-group-btn">
                        <button type="submit" class="btn btn-primary">立即搜索</button>
                        </span>
                    </div>
                </form>
            </div>
            <div class="panel-body table-responsive">
                <table class="table table-hover table-striped">
                    <thead>
                    <tr>
                        <th>卡密</th>
                        <th>状态</th>
                        <th>月数</th>
                        <th>生成时间</th>
                        <th>使用时间</th>
                        <th>使用者QQ</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {volist name="$kmList" id="km"}
                    <tr>
                        <td>{$km.km}</td>
                        <td>{if condition="$km.user"}<font color="red">已使用</font>{else}未使用{/if}</td>
                        <td>{$km.value}</td>
                        <td>{$km.addtime}</td>
                        <td>{$km.usetime}</td>
                        <td>{$km.user}</td>
                        <td><a href="?action=del&kid={$km.kid}" class="btn-xs btn-warning">删除</a></td>
                    </tr>
                    {/volist}
                    </tbody>
                </table>
                <div class="text-center">{$pageList->showPage()}</div>
            </div>
        </div>
    </div>
</div>
</div>
{/block}